package com.qf.first.service.impl;

import com.qf.first.dao.AdminMapper;
import com.qf.first.entity.Order;
import com.qf.first.entity.User;
import com.qf.first.pojo.vo.RespVo;
import com.qf.first.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;

    @Transactional
    @Override
    public User checkUser(User user) {
        User user1 = adminMapper.selectById(user);
        return user1;
    }

    @Override
    public int updateUser(User user) {
        int i = adminMapper.updateUser(user);
        return i;
    }

    @Override
    public Boolean checkCode(String code, HttpSession session) {
        String serveCode = (String) session.getAttribute("serveCode");
        System.out.println(serveCode);
        if (!serveCode.equals(code)){
            return false;
        }
        return true;
    }

    @Override
    public int selectShop() {
        int shopNum = adminMapper.selectShop();
        return shopNum;
    }

    @Override
    public int selectUser() {
        int userNum = adminMapper.selectUser();
        return userNum;
    }

    @Override
    public List<Order> selectOrder() {
        List<Order> orders = adminMapper.selectOrder();
        return orders;
    }
}
